import Vue from 'vue'
import App from './App.vue'
import router from './router'
// element ui 组件库
import ElementUI from 'element-ui';
// element ui 样式
import 'element-ui/lib/theme-chalk/index.css';
import VueRouter from 'vue-router'
Vue.use(VueRouter)

// 捕获push replace中的错误
// 当然在replace中的错误也是可以相同的进行捕获
const originalPush = VueRouter.prototype.push
const originalReplace = VueRouter.prototype.replace
// push
VueRouter.prototype.push = function push(location, onResolve, onReject) {
  console.log(location, onResolve, onReject, "geyaopush is")
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => {
    console.log(err, "geyaoerr is")
  }
  )
}
// replace
VueRouter.prototype.replace = function push(location, onResolve, onReject) {
  console.log(location, onResolve, onReject, "geyaoreplace is")
  if (onResolve || onReject) return originalReplace.call(this, location, onResolve, onReject)
  return originalReplace.call(this, location).catch(err => err)
}
// 使用 element ui
Vue.use(ElementUI);
Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
